package com.diyunapp.xilinapp.selfdefine;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;
import android.widget.ImageView;

import com.bigkoo.convenientbanner.holder.Holder;
import com.diyunapp.xilinapp.R;
import com.nuttysoft.nutand.utils.AppUtil;
import com.nuttysoft.nutand.utils.ViewUtil;
import com.squareup.picasso.Picasso;

/**
 * Created by NIDAYE on 2016/6/28.
 */
public class LocalImageHolderView implements Holder<String> {
    private ImageView imageView;

    @Override
    public View createView(Context context) {
        imageView = new ImageView(context);
        imageView.setScaleType(ImageView.ScaleType.FIT_XY);
        return imageView;
    }

    @Override
    public void UpdateUI(Context context, int position, String data) {
        int screenWidth = AppUtil.getDisplayMetrics(context).heightPixels;
        int targetPicHeight = (int) ViewUtil.dip2px(context, 180);
        Picasso.with(context)
                .load(data)//int) width * 400 / 1392
//                    .resize((int) targetPicHeight * 1392 / 400, targetPicHeight)
//                    .centerCrop()
                .config(Bitmap.Config.RGB_565)
                .error(R.drawable.store_ban_default)
                .placeholder(R.drawable.store_ban_default)
                .into(imageView);
    }
}
